<template>
    <div>
        <table>
            <tbody>
                <tr>
                    <td>病房号</td>
                    <td>
                        <input type="text" v-model="info.Name">
                    </td>
                </tr>
                <tr>
                    <td>所属科室</td>
                    <td>
                        <select name="" v-model="info.KS" id="">
                            <option value="内科">内科</option>
                            <option value="外科">外科</option>
                            <option value="心肺科">心肺科</option>
                            <option value="脑科">脑科</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>床位数</td>
                    <td>
                        <input type="text" v-model="info.Num">
                    </td>
                </tr>
                <tr>
                    <td>状态</td>
                    <td>
                        <input type="radio" name="a" v-model="info.State" :value=true>住满
                        <input type="radio" name="a" v-model="info.State" :value=false>未住满
                    </td>
                </tr>
                <tr>
                    <td>空床位</td>
                    <td>
                        <input type="text" v-model="info.CW">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="添加" @click="add">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();

const info =ref({
    Bid: 0,
  Name: "",
  KS: "",
  Num: "",
  State: true,
  CW: "",
  createtime: "2025-10-11T05:17:17.348Z"
})

const add=()=>{
    if(info.value.Name==""){
        alert("病房号不能为空");
        return;
    }
    if(info.value.Num==""){
        alert("床位数不能为空");
        return;
    }
    if(info.value.CW==""){
        alert("空床位不能为空");
        return;
    }
    axios.post("https://localhost:7168/api/BF/Add",info.value).then((res)=>{
        if(res.data>0){
            alert("添加成功");
            router.push("/Show");
        }
        else{
            alert("添加失败");
        }
    })
}





</script>

<style scoped>

</style>